#!/usr/bin/python
#Looks for LazyFile Scripts, and then executes them
#Copyright (C) 2008 Laseredd1
#This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

import os
import re

class LazyRun(object):
    def __init__(self, Dir):
        self.fList = os.listdir(Dir)
        self.fNum = len(self.fList) - 1
        self.While = 0
        
        self.process()
        
    def process(self):
        while self.While <= self.fNum:
            self.srch = bool(re.search(".LAZY", self.fList[self.While]))
            if self.srch:
                os.system("lazyfile.py " + confloc + self.fList[self.While])
            else: print "Pass"
            self.While += 1

if __name__ == "__main__":    
    print "Lazyfile Launcher"
    print
    print "Lazyfile, Copyright (C) 2008 Laseredd. Lazyfile comes \
with ABSOLUTELY NO WARRANTY; for details see license.txt. This is free \
software, and you are welcome to redistribute it under certain conditions; \
see license.txt for details."
    print
    
    conf = file("lazyfile.conf", "r")
    confloc = conf.readlines(0)
    confloc = "".join(confloc)
    
    fl = LazyRun(confloc)
    
    print
    raw_input("Finished. Press Enter to continue")
